/**
 * Created by zpc on 2017/11/24.
 */
$(function () {

/*
    var stars = 800;
    var $stars = $('.stars');
    var r = 800;
    for (var i = 0; i < stars; i++) {
        if (window.CP.shouldStopExecution(1)) {
            break;
        }
        var $star = $('<div/>').addClass('star');
        $stars.append($star);
    }
    window.CP.exitedLoop(1);
    $('.star').each(function () {
        var cur = $(this);
        var s = 0.2 + Math.random() * 1;
        var curR = r + Math.random() * 300;
        cur.css({
            transformOrigin: '0 0 ' + curR + 'px',
            transform: ' translate3d(0,0,-' + curR + 'px) rotateY(' + Math.random() * 360 + 'deg) rotateX(' + Math.random() * -50 + 'deg) scale(' + s + ',' + s + ')'
        });
    });
*/






    $('#fullpage').fullpage({
        verticalCentered: "true",
        resize: true,
        navigation: true,
        navigationColor: "#fff",
        loopBottom: true,
        loopTop: true,
        afterLoad: function (anchorLink, index) {
            if (index == 1) {
                $('.section1 .buy_1 h1').delay(200).animate({
                    opacity: '1'
                }, 500, 'easeOutExpo');
                $('.section1 .buy_1 h2').delay(300).animate({
                    opacity: '1'
                }, 600, 'easeOutExpo');
                $('.section1 .buy_1 .introduce1').delay(400).animate({
                    opacity: '1'
                }, 700, 'easeOutExpo');
                $('.section1 .buy_1 .purchase1').delay(500).animate({
                    opacity: '1'
                }, 1500, 'easeOutExpo');
            }

            if (index == 2) {
                document.getElementById("videoid").play();
                $('.section2').find('.title_3').delay(2000).animate({
                    left: '15%'
                }, 2000, 'easeOutExpo');

                $('.title_4').delay(1500).animate({
                    left: '15%'
                }, 3000, 'easeOutExpo');
            }
            if (index == 3) {
                $('.section3').find('.introduce2').find('h4').delay(400).animate({
                    opacity: '1'
                }, 1000, 'easeOutExpo');
                $('.section3').find('.introduce2').find('h1').delay(500).animate({
                    opacity: '1'
                }, 1500, 'easeOutExpo');
                $('.section3').find('.introduce2').find('.info').delay(500).animate({
                    opacity: '1'
                }, 1500, 'easeOutExpo');
            }
            if (index == 4) {
                $('.section4').find('.title_2').delay(500).animate({
                    top: '15%',
                    opacity: 1
                }, 1500, 'easeOutExpo');
            }
            if (index == 5) {
                $('.section5').find('.title_5').delay(500).animate({
                    left: '50%'
                }, 1000, 'easeOutExpo');
               /* $('.section5').find('.title_6').delay(500).animate({
                    right: '50%'
                }, 1000, 'easeOutExpo');*/
            }
            if (index == 6) {
                $('.section6').find('.title_1').delay(500).animate({
                    top: '10%',
                    opacity: 1
                }, 1000, 'easeOutExpo');
            }
            if (index == 7) {
                $('.section7').find('.title_1').delay(500).animate({
                    left: '0'
                }, 1000, 'easeOutExpo');
            }
            if (index == '8') {
                $('.section8').find('.title_8_2').delay(300).animate({
                    top: '45%',
                    opacity: 1
                }, 800, 'easeOutExpo');
                $('.section8').find('.title_8').delay(500).animate({
                    opacity: 1,
                    top: '15%'
                }, 1000, 'easeOutExpo');
            }
            if (index == 9) {
                $('.section9').find('.title_1').delay(500).animate({
                    left: '0'
                }, 1000, 'easeOutExpo');
                $('.section9 .icon_box1').delay(500).animate({
                    opacity: '1'
                }, 1000, 'easeOutExpo');
            }

        },
        onLeave: function (index, direction) {
            if (index == '1') {
                $('.section1 .buy_1 h1').delay(200).animate({
                    opacity: '0'
                }, 500, 'easeOutExpo');
                $('.section1 .buy_1 h2').delay(300).animate({
                    opacity: '0'
                }, 600, 'easeOutExpo');
                $('.section1 .buy_1 .introduce1').delay(400).animate({
                    opacity: '0'
                }, 700, 'easeOutExpo');
                $('.section1 .buy_1 .purchase1').delay(500).animate({
                    opacity: '0'
                }, 800, 'easeOutExpo');
            }
            if (index == '2') {

                $('.section2').find('.title_3').delay(500).animate({
                    left: '-120%'
                }, 1000, 'easeOutExpo');


                $('.title_4').delay(200).animate({
                    left: '-120%'
                }, 700, 'easeOutExpo');
            }
            if (index == '3') {
                $('.section3').find('.introduce2').find('h4').delay(500).animate({
                    opacity: '0'
                }, 1500, 'easeOutExpo');
                $('.section3').find('.introduce2').find('h1').delay(500).animate({
                    opacity: '0'
                }, 1500, 'easeOutExpo');
                $('.section3').find('.introduce2').find('.info').delay(500).animate({
                    opacity: '0'
                }, 1500, 'easeOutExpo');
            }
            if (index == '4') {
                $('.section4').find('.title_2').delay(0).animate({
                    opacity: 0,
                    top: '-120%'

                }, 100, 'easeOutExpo');
            }
            if (index == '5') {
                $('.section5').find('.title_5').delay(500).animate({
                    left: '-120%'
                }, 1000, 'easeOutExpo');
                /*$('.section5').find('.title_6').delay(500).animate({
                    right: '-120%'
                }, 1000, 'easeOutExpo');*/
            }
            if (index == '6') {
                $('.section6').find('.title_1').delay(0).animate({
                    opacity: 0,
                    top: '-120%'
                }, 100, 'easeOutExpo');
            }
            if (index == '7') {
                $('.section7').find('.title_1').delay(500).animate({
                    left: '-120%'
                }, 1000, 'easeOutExpo');
            }
            if (index == '8') {
                $('.section8').find('.title_8_2').delay(300).animate({
                    top: '80%',
                    opacity: 0.2
                }, 800, 'easeOutExpo');
                $('.section8').find('.title_8').delay(0).animate({
                    opacity: 0,
                    top: '-120%'
                }, 100, 'easeOutExpo');
            }
            if (index == '9') {
                $('.section9').find('.title_1').delay(500).animate({
                    left: '-120%'
                }, 1000, 'easeOutExpo');
                $('.section9 .icon_box1').delay(500).animate({
                    opacity: '0'
                }, 1000, 'easeOutExpo');
            }

        }
    });

/*图片旋转效果*/
    //photo();


    /*$(".word_box .bt").click(function () {
     /!*$(".box-img3 .introduce2 .photo1 .ring1 .wrap .info").removeClass("b1");*!/
     $(".box-img3 .introduce2 .photo1 .ring1 .wrap .info").addClass("b1");
     setTimeout(function () {
     $(".box-img3 .introduce2 .photo1 .ring1 .wrap .info").removeClass("b1");
     }, 1000)

     })*/

    $(".top").addClass("a1");
    $(".bottom").addClass("a2");
    $(".bt1").mouseover(function () {
        rotate_blue();

    });

    $(".bt2").mouseover(function () {
        rotate_red();
    });

    $(".bt3").mouseover(function () {
        rotate_yellow();
    });

    mouse();
    signal();
    light();
   /* setInterval(function () {
     var fm1=$(".box-img6 .fm_box .fm_signal img");
     var k=0;
     k++;
     fm1.attr("src","/static/images/web/index/f00"+ k +".png");
     console.log(fm1);
     if( k == 0){
     k++;
     }
     if(k==4){
     k=0;
     k++;
     }
     },100)*/




})

var i = 0;
var mmp = false;
setInterval(function () {
    if (mmp) {
        return;
    }
    switch (i) {
        case 0:
            rotate_blue();
            i++;
            break;
        case 1:
            rotate_red();
            i++;
            break;
        case 2:
            rotate_yellow();
            i = 0;
            break;
    }
}, 5000);

function light() {
    var light_img = ["/static/images/web/index/light1.png",
        "/static/images/web/index/light2.png",
        "/static/images/web/index/light3.png",
        "/static/images/web/index/light4.png",
        "/static/images/web/index/light5.png",
        "/static/images/web/index/light6.png",
        "/static/images/web/index/light7.png"];
    var img = $(".box-img4 .light_box img");
    var i = 0;
    var set_1= setInterval(function() {
        img.attr("src", light_img[i]);
        i++;
        i = i > light_img.length - 1 ? 0 : i;
    }, 800);
}
function signal() {
    var tb = ["/static/images/web/index/f000.png", "/static/images/web/index/f001.png", "/static/images/web/index/f002.png", "/static/images/web/index/f003.png", "/static/images/web/index/f004.png"];
    var img = $(".box-img6 .fm_box .fm_signal img");
    var i = 0;
    var interval = setInterval(function() {
        img.attr("src", tb[i]);
        i++;
        i = i > tb.length - 1 ? 0 : i;
    }, 800);
}

function mouse() {
    $(".introduce2 .word_box .bt").mouseover(function () {
        mmp = true;
    });
    $(".introduce2 .word_box .bt").mouseout(function () {
        mmp = false;
    })
}

function rotate_blue() {
    $(".circle").css({"border": ".2rem solid blue"})
    $(".circle").removeClass("red");
    $(".circle").removeClass("yellow");
    $(".circle").addClass("blue");
    $(".top").removeClass("a1");
    $(".bottom").removeClass("a2");
    setTimeout(function () {
        $(".top").addClass("a1");
        $(".bottom").addClass("a2");
    }, 5)
    $(".box-img3 .introduce2 .photo1 .ring1 .wrap .info").html("杀菌、消炎、祛痘");
}
function rotate_red() {
    $(".circle").css({"border": ".2rem solid red"})
    $(".circle").removeClass("yellow");
    $(".circle").removeClass("blue");
    $(".circle").addClass("red");
    console.log($(".circle:before"));
    $(".top").removeClass("a1");
    $(".bottom").removeClass("a2");
    setTimeout(function () {
        $(".top").addClass("a1");
        $(".bottom").addClass("a2");
    }, 5)
    $(".box-img3 .introduce2 .photo1 .ring1 .wrap .info").html("刺激皮肤<br/>胶原蛋白增长。");
}
function rotate_yellow() {
    $(".circle").css({"border": ".2rem solid yellow"})
    $(".circle").removeClass("blue");
    $(".circle").removeClass("red");
    $(".circle").addClass("yellow");

    $(".top").removeClass("a1");
    $(".bottom").removeClass("a2");
    setTimeout(function () {
        $(".top").addClass("a1");
        $(".bottom").addClass("a2");
    }, 5)
    $(".box-img3 .introduce2 .photo1 .ring1 .wrap .info").html("促进皮肤<br/>及淋巴系统微循环。");
}


function photo() {
    var i = 0;
    var d = 0;
    setInterval(function () {
        /*背景图片改为IMG显示，看看效果 何磊瞎几把高*/
  /*      $(".box-img1 .buy_1 .cont").css({
            "background-image": "url(/static/images/web/img/" + i + ".png)",
            "background-size": "100%",
            "background-repeat": "no-repeat",
            "background-position": "50% 50%"
        })*/
  var imgPath="/static/images/web/img/" + i + ".png";


        $(".box-img1 .buy_1 .cont .t_img img").attr("src",imgPath);
        //i = (i == 73) ? 1 : i + 1;
        if (i == 73) {

            i--;
            d = 73;

        }
        if (d == 73) {
            i--;
        } else {
            i++;
        }
        if (i == 0) {
            i++;
            d = 0;
        }
    }, 100)
}